home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Sample Code / Sample Editors⁄Viewers / Panel Editor / Source / PanelEditor.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-08  |  8.8 KB  |  286 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        PanelEditor.h
  3.  
  4.     Contains:    Sample part editor class implementation
  5.  
  6.     Written by:    Steve Smith
  7.     
  8.     Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  9. */
  10.  
  11. #ifndef _PANELEDITOR_
  12. #define _PANELEDITOR_
  13.  
  14. // -- Compiler/Preprocessor Switches --
  15.  
  16. #ifndef _COMPILERDEFS_
  17. #include "CompDefs.h"
  18. #endif
  19.  
  20. // -- PanelEditor Includes --
  21.  
  22. #ifndef _PANELEDITORDEF_
  23. #include "PanelEditorDef.h"
  24. #endif
  25.  
  26. // -- OpenDoc Includes --
  27.  
  28. #ifndef _ODTYPES_
  29. #include <ODTypes.h>
  30. #endif
  31.  
  32.  
  33. class ODFacet;
  34. class ODFocusSet;
  35. class ODFrame;
  36. class ODMenuBar;
  37. class ODShape;
  38. class ODStorageUnit;
  39. class ODWindow;
  40. class CList;
  41. class CScrollbar;
  42. class CSelection;
  43. class CPanel;
  44. class CScrollingList;
  45. class CListItem;
  46. class COrderedList;
  47. class CPrinter;
  48.  
  49. struct WindowProperties;
  50.  
  51. //----------------------------------
  52. // Class Defs
  53. //----------------------------------
  54.  
  55. class PanelEditor {
  56.     
  57.     public:
  58.     
  59.     PanelEditor();
  60.     virtual ~PanelEditor();
  61.     
  62.     // -- Initialization --
  63.     
  64.     void        InitPart(Environment* ev, ODStorageUnit* storageUnit,
  65.                                         ODPart* partWrapper);
  66.     void        InitPartFromStorage(Environment* ev, ODStorageUnit* storageUnit,
  67.                                         ODPart* partWrapper);
  68.     
  69.     // -- Storage --
  70.     
  71.     void        Release(Environment* ev);
  72.     void        ReleaseAll(Environment* ev);
  73.     ODSize        Purge(Environment* ev, ODSize size);
  74.     void        Externalize(Environment* ev);
  75.     void        ExternalizeKinds(Environment* ev, ODTypeList* kindset);
  76.     void        ChangeKind(Environment* ev, ODType kind);
  77.     void        CloneInto(Environment* ev, ODDraftKey key,
  78.                                         ODStorageUnit* destinationSU,
  79.                                         ODFrame* initiatingFrame);
  80.     void        WritePartInfo(Environment* ev, ODInfoType partInfo,
  81.                                         ODStorageUnitView* storageUnitView);
  82.     ODInfoType    ReadPartInfo(Environment* ev, ODFrame* frame,
  83.                                         ODStorageUnitView* storageUnitView);
  84.     void        ClonePartInfo(Environment *ev, ODDraftKey key, ODInfoType partInfo,
  85.                                         ODStorageUnitView* storageUnitView,
  86.                                         ODFrame* scopeFrame);
  87.     void        SetDirty(Environment* ev);
  88.     
  89.     // -- Layout --
  90.     
  91.     void        DisplayFrameAdded(Environment* ev, ODFrame* frame);
  92.     void        DisplayFrameRemoved(Environment* ev, ODFrame* frame);
  93.     void        DisplayFrameClosed(Environment* ev, ODFrame* frame);
  94.     void        DisplayFrameConnected(Environment* ev, ODFrame* frame);
  95.     void        AttachSourceFrame(Environment* ev, ODFrame* frame,
  96.                                         ODFrame* sourceFrame);
  97.     void        ViewTypeChanged(Environment* ev, ODFrame* frame);
  98.     void        FrameShapeChanged(Environment* ev, ODFrame* frame);
  99.     ODShape*    RequestFrameShape(Environment *ev, ODFrame* embeddedFrame,
  100.                                         ODShape* frameShape);
  101.     ODID        Open(Environment* ev, ODFrame* frame);
  102.         
  103.     // -- Imaging --
  104.     
  105.     void        Draw(Environment* ev, ODFacet* facet, ODShape* invalidShape);
  106.     void        GeometryChanged(Environment* ev, ODFacet* facet,
  107.                                         ODBoolean clipShapeChanged,
  108.                                         ODBoolean externalTransformChanged);
  109.     void        HighlightChanged(Environment* ev, ODFacet* facet);
  110.     void        FacetAdded(Environment* ev, ODFacet* facet);
  111.     void        FacetRemoved(Environment* ev, ODFacet* facet);
  112.     ODShape*    AdjustBorderShape(Environment *ev, ODFacet* embeddedFacet,
  113.                                         ODShape* shape);
  114.     CListItem*    GetItemNearSelection();
  115.     void        UpdateSelection(Environment* ev, CListItem* item);
  116.     
  117.     // -- Activation --
  118.     
  119.     ODBoolean    BeginRelinquishFocus(Environment* ev, ODTypeToken focus,
  120.                                         ODFrame* ownerFrame,
  121.                                         ODFrame* proposedFrame);
  122.     void        CommitRelinquishFocus(Environment* ev, ODTypeToken focus,
  123.                                         ODFrame* ownerFrame,
  124.                                         ODFrame* proposedFrame);
  125.     void        AbortRelinquishFocus(Environment* ev, ODTypeToken focus,
  126.                                         ODFrame* ownerFrame,
  127.                                         ODFrame* proposedFrame);
  128.     void        FocusAcquired(Environment* ev,ODTypeToken focus,
  129.                                         ODFrame* ownerFrame);
  130.     void        FocusLost(Environment* ev,ODTypeToken focus,
  131.                                         ODFrame* ownerFrame);
  132.     
  133.     // -- Event Handling --
  134.     
  135.     ODBoolean    HandleEvent(Environment* ev, ODEventData* event,
  136.                                         ODFrame* frame, ODFacet* facet,
  137.                                         ODEventInfo* eventInfo);
  138.     void        AdjustMenus(Environment* ev, ODFrame* frame);
  139.     
  140.  
  141. #ifndef PE_ViewerBuild
  142.     // -- Drag and Drop --
  143.     
  144.     ODDragResult    DragEnter(Environment *ev, ODDragItemIterator* dragInfo,
  145.                                         ODFacet* facet, ODPoint* where);
  146.     ODDragResult    DragWithin(Environment *ev, ODDragItemIterator* dragInfo,
  147.                                         ODFacet* facet, ODPoint* where);
  148.     void            DragLeave(Environment *ev, ODFacet* facet, ODPoint* where);
  149.     ODDropResult    Drop(Environment *ev, ODDragItemIterator* dropInfo,
  150.                                         ODFacet* facet, ODPoint* where);
  151. #endif
  152.     
  153.     // -- Undo --
  154.     void        UndoAction(Environment* ev, ODActionData* actionState);
  155.     void        RedoAction(Environment* ev, ODActionData* actionState);
  156.     void        DisposeActionState(Environment* ev, ODActionData* actionState,
  157.                                         ODDoneState doneState);
  158.  
  159.     // -- Embedding --
  160.     
  161.     void        RemoveListItem(Environment* ev, CListItem* item);
  162.         
  163.     // -- Utilities --
  164.     
  165.     ODPart*            GetSelf();
  166.     COrderedList*    GetEmbeddedItems();
  167.  
  168.  
  169.   //------------------------------------
  170.     protected:
  171.     
  172.     // -- Initialization --
  173.     
  174.     void        Initialize(Environment* ev);
  175.     
  176.     // -- Storage --
  177.     
  178.     void        CheckAndAddProperties(Environment* ev,
  179.                                         ODStorageUnit* storageUnit);
  180.     void        CleanseContentProperty(Environment* ev,
  181.                                         ODStorageUnit* storageUnit);
  182.     void        InternalizeStateInfo(Environment* ev,
  183.                                         ODStorageUnit* storageUnit);
  184.     void        InternalizeContent(Environment* ev,
  185.                                         ODStorageUnit* storageUnit);
  186.     void        ExternalizeStateInfo(Environment* ev,
  187.                                         ODStorageUnit* storageUnit,
  188.                                         ODDraftKey key, ODFrame* scopeFrame);
  189.     void        ExternalizeContent(Environment* ev, ODStorageUnit* storageUnit,
  190.                                         ODDraftKey key, ODFrame* scopeFrame);
  191.     ODBoolean    CheckClipboard(Environment* ev, ODFrame* frame);
  192.     
  193.     // -- Event Handling --
  194.     
  195.     ODBoolean    HandleMenuEvent(Environment* ev, ODEventData* event,
  196.                                            ODFrame* frame);
  197.     ODBoolean    HandleMouseEvent(Environment* ev, ODEventData* event,
  198.                                         ODFacet* facet, ODEventInfo* eventInfo);
  199.     void        DoDialogBox(Environment* ev, ODFrame* frame,
  200.                                           ODSShort dialogID, ODUShort errorNumber = 0);
  201.     void        DoPartInfo(Environment* ev, ODFrame* frame);
  202.     void        DoCut(Environment* ev, ODFrame* frame);
  203.     void        DoCopy(Environment* ev, ODFrame* frame);
  204.     void        DoPaste(Environment* ev, ODFrame* frame);
  205.     void        DoPasteAs(Environment* ev, ODFrame* frame);
  206.     void        DoClear(Environment* ev, ODFrame* frame);
  207.     void        DoUndo(Environment* ev, ODFrame* frame);
  208.     void        DoRedo(Environment* ev, ODFrame* frame);
  209.     
  210.     // -- Imaging --
  211.     
  212.     void        DrawFrameView(Environment* ev, ODFacet* facet);
  213.     void        DrawIconView(Environment* ev, ODFacet* facet);
  214.     void        DrawThumbnailView(Environment* ev, ODFacet* facet);
  215.     PicHandle    GenerateThumbnail( Environment*    ev, ODFrame* frame);
  216.  
  217.     // -- Activation --
  218.     
  219.     void        PartActivated(Environment* ev, ODFrame* frame);
  220.     ODBoolean    ActivateFrame(Environment* ev, ODFrame* frame);
  221.     void        WindowActivating(Environment* ev, ODFrame* frame, ODBoolean activate);
  222.     void        ProcessActivating(Environment* ev, ODFrame* frame, ODBoolean resume);
  223.     void        RelinquishAllFoci(Environment* ev, ODFrame* frame);
  224.     
  225.     // -- Layout --
  226.     
  227.     ODWindow*    AcquireFramesWindow(Environment* ev, ODFrame* frame);
  228.     ODWindow*    CreateWindow(Environment* ev, ODFrame* frame, ODType frameType,
  229.                                         WindowProperties* windowProperties);
  230.     void        CleanupWindow(Environment* ev, ODFrame* frame);
  231.     WindowProperties*    GetDefaultWindowProperties(Environment* ev, ODFrame* frame,
  232.                                         Rect* windowRect);
  233.     WindowProperties*    GetSavedWindowProperties(Environment* ev, ODFrame* frame);
  234.     Rect        CalcPartWindowSize(Environment* ev, ODFrame* sourceFrame);
  235.     Rect        CalcPartWindowPosition(Environment* ev, ODFrame* frame,
  236.                                         Rect* partWindowBounds);
  237.     ODFacet*    GetActiveFacetForFrame(Environment* ev, ODFrame* frame);
  238.     ODShape*    CalcNewUsedShape(Environment* ev, ODFrame* frame);
  239.     void        UpdateFrame(Environment* ev, ODFrame* frame, ODTypeToken view,
  240.                                         ODShape* usedShape);
  241.     void        CleanupDisplayFrame(Environment* ev, ODFrame* frame,
  242.                                         ODBoolean frameRemoved);
  243.     void        CleanupEmbeddedFrames(Environment* ev, ODFrame* containingFrame,
  244.                                         ODBoolean frameRemoved);
  245.     void        ZoomPartWindow(Environment* ev, ODFrame* frame, ODWindow* window,
  246.                                         ODBoolean openingWindow);
  247.                                         
  248.     // -- Embedding --
  249.     
  250.     void        EmbedNewItem(Environment* ev, ODFacet* facet, ODID partID);
  251.  
  252.     // --- Getters ---
  253.  
  254.     ODUShort    GetMinHeight();
  255.     ODUShort    GetMinWidth();
  256.     
  257.       //========================
  258.     private:
  259.  
  260.     ODPart*            fSelf;
  261.     CList*            fDisplayFrames;
  262.     CPrinter*        fPrinter;
  263.  
  264.     COrderedList*    fEmbeddedParts;
  265.     CSelection*        fSelection;
  266.     CPanel*            fPanel;
  267.     CScrollingList*    fList;
  268.  
  269.     ODBoolean        fReadOnlyStorage;
  270.     ODBoolean        fDirty;
  271.     ODBoolean        fNegotiating;
  272. };
  273.  
  274.  
  275. //-----------------------------------------------------------------------------
  276. // Inlines
  277. //-----------------------------------------------------------------------------
  278.  
  279. inline ODUShort PanelEditor::GetMinHeight()
  280. { return (2*kListItemHeight+2*kListTopEdge); }
  281.  
  282.  
  283. inline ODUShort PanelEditor::GetMinWidth()
  284. { return (kPanelLeftEdge+kMinPanelWidth); }
  285.  
  286. #endif